<!DOCTYPE html>
<html>

<head lang="en">
    <title>首页</title>
    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <script src="/js/jquery/jquery.min.js"></script>
    <link rel="stylesheet" href="/js/bootstrap-4.1.1-dist/css/bootstrap.min.css">
    <script src="/js/bootstrap-4.1.1-dist/js/bootstrap.min.js"></script>
    <script src="js/emojiCursor.js" type="text/javascript"></script>
    <link rel="stylesheet" href="/css/font/css/font-awesome.min.css">
    <link rel="stylesheet" href="/css/reset.css" rel="stylesheet">
    <link rel="stylesheet" href="/css/index.css" rel="stylesheet">
    <script src="/js/plugins/jrender/jrender.min.js"></script>
    <script src="/js/common.js"></script>
    <link rel="stylesheet" href="/js/plugins/dialog2/dialog.css">
    <script src="/js/plugins/dialog2/dialog.min.js"></script>
    <script>

        $(function () {
            showComments();
            //每周推荐回显
            $.get(baseUrl + "travelCommonds", {type: 1}, function (data) {
                $("#travelsCommends").renderValues(data, {
                    'getHref': getHref
                });
                $(".carousel-item:first").addClass('active');
            })


            $.get(baseUrl + "/news/", {currentPage: 1}, function (data) {
                $('#bigger').renderValues(data.list[0], {
                    getHref: getHref
                });

                var arrAll = [];
                var arr = [];
                $.each(data.list, function (index, ele) {
                    if (index != 0) {
                        arr = $(ele).toArray();
                        $.merge(arrAll, arr);
                    }
                });

                $("#smaller").renderValues({list: arrAll}, {
                    getHref: getHref
                });
            });

            $('#comments').click(function () {
                window.location.href = "/mine/comment.html"
            })

            //页头搜索功能
            $("#searchBtn").click(function () {
                var keyword = $("#search").val();
                if (keyword != null & keyword != "") {
                    window.location.href = "/searchPage.html?keyword=" + keyword;
                } else {
                    $(document).dialog({

                        titleText: '温馨提示',
                        content: '亲,搜索内容不能为空!'
                    });
                }
            });
            //第一次进入查询一次本地天气
            $citycode = urlencode("广州");
            url = 'http://v.juhe.cn/weather/index?format=2&cityname=' + $citycode + '&key=97c3e78fdfc538dd6418d7141ddfc17f';
            $.ajax({
                url: url,
                dataType: "jsonp",
                type: "get",

                data: {location: city},
                success: function (data) {
                    var sk = data.result.sk;
                    var today = data.result.today;
                    var futur = data.result.future;
                    var fut = "日期温度天气风向";
                    $("#roll").html("<p style='padding-bottom: 10px;'>" + today.city + ' 今天是:  ' + today.date_y + ' ' + today.week + ' , ' + today.temperature + ' , ' + today.weather + ' , ' + today.wind + "<p>")

                }
            });
            //天气查询功能
            $('#searcha').on('click', function () {

                var city = $('#city').val() || '北京';
                getWeather(city)
            });

            function getWeather(city) {
                $citycode = urlencode(city);

                url = 'http://v.juhe.cn/weather/index?format=2&cityname=' + $citycode + '&key=97c3e78fdfc538dd6418d7141ddfc17f';
                $.ajax({
                    url: url,
                    dataType: "jsonp",
                    type: "get",

                    data: {location: city},
                    success: function (data) {
                        var sk = data.result.sk;
                        var today = data.result.today;
                        var futur = data.result.future;
                        var fut = "日期温度天气风向";
                        $(document).dialog({
                            titleShow: false,
                            content: "<p>" + '当前:  ' + sk.temp + '℃  , ' + sk.wind_direction + sk.wind_strength + ' , ' + '空气湿度' + sk.humidity + ' , 更新时间' + sk.time + "</p><p style='padding-bottom: 10px;'>" + today.city + ' 今天是:  ' + today.date_y + ' ' + today.week + ' , ' + today.temperature + ' , ' + today.weather + ' , ' + today.wind + "<p></p>" + "<p>" + '未来:  ' + futur[0].temperature + '℃  , ' + futur[0].weather + futur[0].wind + ' , ' + ' , 更新时间' + futur[0].week + futur[0].date + "</p><p style='padding-bottom: 10px;'>" + today.city + "<p></p>"
                        });

                    }
                });
            }

            function urlencode(str) {
                str = (str + '').toString();

                return encodeURIComponent(str).replace(/!/g, '%21').replace(/'/g, '%27').replace(/\(/g, '%28').replace(/\)/g, '%29').replace(/\*/g, '%2A').replace(/%20/g, '+');
            }
        })
    </script>
    <style>
        .w {
            height: 20px;margin: 0px;padding: 0px;
        }
    </style>
</head>


<body>

<div class="body">

    <input type="checkbox" id="menu">

    <label for="menu" class="menu">
        <span><i class="fa fa-user fa-fw fa-2x"></i></span>
        <span><i class="fa fa-chevron-left fa-fw fa-2x" style="color: #3E3C3B"></i></span>
    </label>

    <!-- 侧边栏 -->
    <div class="nav">
        <iframe id="ipage" src="/mine/simpleProfiles.html" frameborder="0" width="90%"></iframe>
    </div>
    <!--搜索栏-->
    <div class="search-head">
        <div class="row nav-search">
            <div class="col-1"></div>
            <div class="col-9">
                <div class="input-group-sm search">
                    <input id="search" class="form-control" placeholder="搜索旅行攻略、日记和旅游资讯">
                </div>
            </div>
            <div class="col-1">
                <i class="fa fa-search" id="searchBtn"
                   style="color:white;font-size:25px;position: absolute;top: 23%;left: 88%">
                </i>
            </div>
        </div>
    </div>

    <div id="mf_weather">
        <marquee behavior=alternate id="roll" class="w"></marquee>
        <button id="searcha" class="btn btn-warning">天气查询</button>
        <input id="city" type="text" placeholder="请输入查询的城市如:北京" size="40%">
    </div>
    <div class="container">
        <h6 class="module-title"><img src="/img/logo.png" width="100%">每周推荐</h6>
        <div id="carouselExampleControls" class="carousel slide" data-ride="carousel">
            <div id="travelsCommends">
                <div class="carousel-inner" render-loop="list">
                    <div class="carousel-item">
                        <a data-url="travelContent.html?id=" render-fun="getHref"
                           render-key="list.travelId">
                            <img class="d-block w-100" render-src="list.coverUrl" width="100%"
                                 height="200px">
                            <span class="recommend" render-html="list.title"></span></a>
                        <div class="recommend-author">
                            <a data-url="userProfiles.html?id=" render-fun="getHref" render-key="list.userId">
                                <img class="rounded-circle" style="width: 10%;" render-src="list.userheadImgUrl">
                                <span render-html="list.userNickName"></span>
                            </a>在&nbsp;
                            <span render-html="list.placeName"></span>
                        </div>
                    </div>
                </div>
            </div>
            <a class="carousel-control-prev" href="#carouselExampleControls" role="button"
               data-slide="prev">
                <span class="carousel-control-prev-icon" aria-hidden="true"></span>
                <span class="sr-only"></span>
            </a>
            <a class="carousel-control-next" href="#carouselExampleControls" role="button"
               data-slide="next">
                <span class="carousel-control-next-icon" aria-hidden="true"></span>
                <span class="sr-only"></span>
            </a>
        </div>
        <hr>

        <div class="row nav-box">
            <div class="col" style="background-color: #DFE823;" align="center">
                <a href="strategyPage.html"><i class="fa fa-plane fa-fw"></i> 找攻略</a>
            </div>
            <div class="col" style="background-color: #7281D5;" align="center">
                <a href="travelPage.html"><i class="fa fa-book fa-fw"></i> 看游记</a>
            </div>
        </div>
        <div class="row nav-box">
            <div class="col" style="background-color: aquamarine;" align="center">
                <a href="question.html"><i class="fa fa-question-circle fa-fw"></i> 问达人</a>
            </div>
            <div class="col" style="background-color: #7281D5;" align="center">
                <a href="together.html"><i class="fa fa-users fa-fw"></i> 约伴</a>
            </div>
        </div>

        <div class="row dynamic " id="comments">
            <div class="col-1" style="padding: 0px;">
                <img class="rounded" src="/img/topComment.png" style="width: 50px;">
            </div>
            <div class="col">
                <div class="Marquee">
                    <div class="d-flex">
                        <a href="userProfiles.html">
                            <img class="rounded-circle dynamic-head"
                                 src="/upload/6610317b-2077-4bd3-98c7-7d31b6613469.jpg">
                        </a>
                        <a href="strategyComment.html" class="dynamic-detail" data-id="1">
                            <p> 叩丁浪广告位招租</p>
                        </a>
                    </div>
                    <div class="d-flex">
                        <a href="userProfiles.html">
                            <img class="rounded-circle dynamic-head"
                                 src="/upload/23a45130-e59c-4844-bc52-67aed3d57fc1.jpeg">
                        </a>
                        <a href="strategyComment.html" class="dynamic-detail">
                            <p>学java哪家强,中国广州叩丁狼</p>
                        </a>
                    </div>
                </div>
            </div>
        </div>
    </div>


    <hr>

    <div class="container">
        <h6 class="module-title">骡爸爸资讯 <a href="/newsPage.html">更多</a></h6>


        <div class="news " id="bigger">
            <a data-url="/newsContent.html?id=" render-key="id" render-fun="getHref">
                <img width="100%" render-src="coverUrl">
                <div class="caption">
                    <h5 render-html="title"></h5>
                    <p render-html="subtitle">
                    </p>
                    <span class="fl-r">
                浏览量:&nbsp;&nbsp;<b style="font-size: 15px;" render-html="browseNum"></b>
                &nbsp;&nbsp;&nbsp;&nbsp;BY&nbsp;&nbsp;<b style="font-size: 15px;">骡爸爸官方</b>
            </span>
                </div>
            </a>
        </div>

        <hr>
        <div id="smaller">
            <div render-loop="list">
                <div style="margin-bottom: 20px">
                    <a render-key="list.id" render-fun="getHref" data-url="/newsContent.html?id=">
                        <div class="row news-detail">
                            <div class="col-5">
                                <img render-src="list.coverUrl">
                            </div>
                            <div class="col-7">
                                <h4 render-html="list.title"></h4>
                                <p render-html="list.subtitle"></p>
                                <span class="fl-r">
                浏览量:&nbsp;&nbsp;<b style="font-size: 15px;" render-html="list.browseNum"></b>
                &nbsp;&nbsp;&nbsp;&nbsp;BY&nbsp;&nbsp;<b style="font-size: 15px;">骡爸爸官方</b>
            </span>
                            </div>
                        </div>
                    </a>
                    <hr>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    function showComments() {
        var Mar = document.getElementsByClassName("Marquee")[0];
        var child_div = Mar.getElementsByTagName("div");
        var picH = 50;//移动高度
        var scrollstep = 3;//移动步幅,越大越快
        var scrolltime = 20;//移动频度(毫秒)越大越慢
        var stoptime = 3000;//间断时间(毫秒)
        var tmpH = 0;
        Mar.innerHTML += Mar.innerHTML;

        function start() {
            if (tmpH < picH) {
                tmpH += scrollstep;
                if (tmpH > picH) tmpH = picH;
                Mar.scrollTop = tmpH;
                setTimeout(start, scrolltime);
            } else {
                tmpH = 0;
                Mar.appendChild(child_div[0]);
                Mar.scrollTop = 0;
                setTimeout(start, stoptime);
            }
        }

        setTimeout(start, stoptime)
    }

</script>

</body>

</html>